package pe.edu.upc.dsd.jjjar.upcbank.client;

import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;

public class AfiliacionController extends Controller {

	private AfiliacionView view;
	
	public AfiliacionController() {
	    registerEventTypes(AppEvents.Afiliaciones);
	    registerEventTypes(AppEvents.Afiliar);
	    registerEventTypes(AppEvents.Desafiliar);
	    
	}

	@Override
	protected void initialize() {
		view = new AfiliacionView(this);
	}
	
	@Override
	public void handleEvent(AppEvent event) {
		EventType type = event.getType();
	    if (type == AppEvents.Afiliaciones || type == AppEvents.Afiliar || type ==  AppEvents.Desafiliar) {
	    	onAfiliacion(event);
	    }
	}
	
	private void onAfiliacion(AppEvent event){
		forwardToView(view, event);
	}
	
	public AfiliacionView getView() {
		return view;
	}
	
}
